#include <iostream>

using namespace std;

int main() {
    int n; //n个整数
    scanf("%d",&n);
    int a[n];
    for (int i = 0; i <n; ++i) {
        scanf("%d",&a[i]);
    }
    int max=a[0];
    int min=a[0];
    //找最大值
    for (int i = 0; i <n ; ++i) {
        if (a[i]>max){
            max=a[i];
        }
    }
    //找最小值
    for (int i = 0; i <n; ++i) {
        if (a[i]<min){
            min=a[i];
        }
    }
    printf("%d",max-min);
    return 0;
}
